home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MAIL.SWG / 0006_Making a FIDO Message.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  2KB  |  93 lines

  1. {
  2. MARK LEWIS
  3.  
  4. > I've been playing with those files in MKMSG101.ZIP ... I've had
  5. > them for awhile, but cannot get them to work.
  6.  > All I'm trying to do is make a simple message in FIDO format for
  7.  > my BBS.  Does anyone have any examples?
  8.  
  9. little to no error checking... tossed together from part(s) of the sample
  10. WRITEMSG.PAS example that comes with MKMSGSRC...
  11. }
  12.  
  13. program sample_MKMSG_code;
  14.  
  15. { reads a text file specified on the command line and posts it
  16.   to specified directory in *.MSG format. }
  17.  
  18. Uses
  19.   DOS, CRT, MKString, MKGlobt,
  20.   MKMsgAbs, MKFile, MKDos, MKMsgFid;
  21.  
  22. Var
  23.   TheMSG  : AbsMsgPtr;
  24.   Error   : Boolean;
  25.   MSGDir,
  26.   TheName,
  27.   TheLine : String;
  28.   TheFile : Text;
  29.   MSGNum  : Word;
  30.  
  31. Begin
  32.   If ParamCount < 2 Then
  33.   Begin
  34.     Writeln('Usage : ' + Paramstr(0) + ' <MSG Dir> <Text file to post>');
  35.     halt(1);
  36.   End;
  37.   Error   := False;
  38.   MSGDir  := WithBackSlash(Upper(Paramstr(1)));
  39.   TheName := Upper(Paramstr(2));
  40.   Assign(TheFile, TheName);
  41.   {$I-}
  42.   Reset(TheFile);
  43.   {$I+}
  44.   Error := IOResult <> 0;
  45.   If Not Error Then
  46.   Begin
  47.     TheMSG := New(FidoMsgPtr, Init);
  48.     TheMSG^.SetMsgPath(MSGDir);
  49.     Error := (TheMSG^.OpenMsgBase <> 0);
  50.     If Not Error Then
  51.     Begin
  52.       TheMSG^.SetMailType(mmtNormal);
  53.       TheMSG^.StartNewMsg;
  54.       TheMSG^.SetFrom('SysOp');
  55.       TheMSG^.SetTo('ALL');
  56.       TheMSG^.SetSubj(TheName);
  57.       TheMSG^.SetPriv(False);
  58.       TheMSG^.SetDate(DateStr(GetDosDate));
  59.       TheMSG^.SetTime(TimeStr(GetDosDate));
  60.       TheMSG^.SetLocal(True);
  61.       TheMSG^.SetEcho(False);
  62.       TheMSG^.SetRefer(0);
  63.       While Not EOF(TheFile) Do
  64.       Begin
  65.         ReadLn(TheFile, TheLine);
  66.         TheMSG^.DoStringLn(TheLine);
  67.       End;
  68.       Error := TheMSG^.WriteMsg <> 0;
  69.       If Not Error Then
  70.       Begin
  71.         MsgNum := TheMSG^.GetMsgNum;
  72.         Writeln('File ', TheName, ' posted to Area ', MSGDir, ' as MSG # ',
  73.                 MSGNum,'.');
  74.       End
  75.       Else
  76.       Begin
  77.         Writeln('Message Creation Error!');
  78.         Halt(4);
  79.       End;
  80.       If TheMSG^.CloseMsgBase <> 0 Then; {Close msg base}
  81.     End
  82.     Else
  83.     Begin
  84.       Writeln('Cannot Open Message Area ', MSGDir, '!');
  85.       Dispose(TheMSG, Done); {Dispose of the object pointer}
  86.       Halt(3);
  87.     End;
  88.     Dispose(TheMSG, Done); {Dispose of the object pointer}
  89.   End
  90.   Else
  91.     Writeln('OOPS! Cannot Locate File ', TheName, '!');
  92. End.
  93.